package com.huidian.resource.server.config;

import com.huidian.cache.config.CaffCacheProperties;
import com.huidian.cache.handler.IPublishResourceModify;
import com.huidian.cache.handler.ISubscribeResourceModify;
import com.huidian.cache.handler.RedisPublishResourceModify;
import com.huidian.cache.handler.RedisSubscribeResourceModify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.Executor;

/**
 * @author tjs
 */
@Configuration
public class CaffRedisCacheConfig {
    /*@Bean
    public IPublishResourceModify publishResourceModify(RabbitTemplate rabbitTemplate, CaffCacheProperties caffCacheProperties){
        return new RabbitmqPublishResourceModify(rabbitTemplate,caffCacheProperties.getRabbitmq().getFanoutexchange());
    }

    @Bean
    public ISubscribeResourceModify subscribeResourceModify(@Autowired Executor taskExecutor){
        return new RabbitmqSubscribeResourceModify(taskExecutor);
    }*/

    @Bean
    public IPublishResourceModify publishResourceModify(RedisTemplate redisTemplate, CaffCacheProperties caffCacheProperties){
        return new RedisPublishResourceModify(redisTemplate,caffCacheProperties.getRedis().getChannel());
    }

    @Bean
    public ISubscribeResourceModify subscribeResourceModify(@Autowired Executor taskExecutor){
        return new RedisSubscribeResourceModify(taskExecutor);
    }
}
